home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscGraphNode.h < prev    next >
Encoding:
Text File  |  1995-04-12  |  3.3 KB  |  115 lines

  1. // Copyright (C) 1995 Todd Thomas
  2.  
  3. /************************************************************************
  4.   CLASS:            MiscGraphNode
  5.   INHERITS FROM:    Object
  6.   PROGRAMMER:        Todd Thomas     (todd@avocado.supernet.ab.ca)
  7.   BEGAN:            June 6, 1994
  8.   LAST CHANGED:        September 14, 1994
  9.   VERSION:            0.5
  10.  
  11.  This class represents a node in a directed graph. Each node contains a list
  12.  of children, parents, and an announcer (for node dependancies). The state
  13.  of the children's list determines if it is a leaf or not. If the method
  14.  -children returns nil, then you are a leaf. A children's list of count zero
  15.  is still a non-leaf node (it just happens to have no children right now).
  16.  The default is to be a leaf node. To change that, either use setLeaf: NO
  17.  or add some children to the node.
  18.  
  19.  Each object takes care of it's own garbage collection by freeing itself when 
  20.  it no longer has any parents or users. The list of parents is kept only for  
  21.  garbage collection and easy traversal of the graph in both directions. 
  22.  
  23.  This class is responsible for the basics of adding/removing children,
  24.  parents, users and listeners, along with it's own garbage collection. 
  25.  Anything more complicated should be a subclass. (See MiscFile)
  26.   
  27.  Anyone familiar with Scott Roy's IconKit will recognize many of the methods
  28.  this class uses. Since so much of the content (interface and protocols) of
  29.  this object comes from the IconKit, I would definitely suggest you take a 
  30.  look at it. It can be found on cs.orst.edu in /pub/next/sources/objects. 
  31.  
  32.  For more information on the announcer object, see it's documentation.
  33.  
  34.  This object is included in the MiscKit by permission from the author
  35.  and its use is governed by the MiscKit license, found in the file
  36.  "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  37.  for a list of all applicable permissions and restrictions.
  38.       
  39.  *************************************************************************/
  40.  
  41. #import <misckit/MiscDependency.h> 
  42. #import <objc/Object.h>
  43.  
  44. @class List;
  45. @class MiscAnnouncer;
  46.  
  47.  
  48. @interface MiscGraphNode: Object <MiscDependency>
  49. {
  50.     List  *children;            // list of node's children
  51.     List  *parents;                // list of node's parents (strictly for gc)
  52.     MiscAnnouncer  *announcer;    // announcer object 
  53. }
  54.  
  55. + initialize;
  56. - init;
  57. - free;
  58.  
  59. - (BOOL)isLeaf;
  60. - setLeaf: (BOOL)isALeaf;
  61.  
  62. - announce: (SEL)announcement;
  63.  
  64. // methods for child maniplulation
  65.  
  66. - children;
  67. - addChild: aChild;
  68. - addChildren: theChildren;
  69. - removeChild: aChild;
  70. - removeChildren: theChildren;
  71.  
  72. // methods for parent manipulation
  73.  
  74. - parents;
  75. - addParent: aParent;
  76. - removeParent: aParent;
  77.  
  78. // methods for garbage collection
  79.  
  80. - checkForFree;
  81. - (BOOL)garbageCollect;
  82.  
  83. // methods for keeping track of dependancies between nodes and other objects
  84. // these are from the IKDependency protocol
  85.  
  86. - addUser: aUser;
  87. - removeUser: aUser;
  88. - addListener: aListener;
  89. - removeListener: aListener;
  90.  
  91. // Archiving
  92.  
  93. - awake;
  94. - read: (NXTypedStream *)stream;
  95. - write: (NXTypedStream *)stream;
  96.  
  97. @end
  98.  
  99.  
  100. // These notifications will be sent to any users and/or listeners that
  101. // are registered with the MiscGraphNode's announcer.
  102.  
  103. @interface Object (MiscGraphNodeNotification)
  104.  
  105. - didAddChild: sender;
  106. - didAddChildren: sender;
  107. - didAddParent: sender;
  108. - didRemoveChild: sender;
  109. - didRemoveChildren: sender;
  110. - didRemoveParent: sender;
  111. - willFree: sender;
  112.  
  113. @end
  114.  
  115.